#include <iostream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cstdlib>

using namespace std;

#define SRAND 1234567

/*
map 1000000:100000 : 283
unordered_map 1000000:100000 : 141
map 100000:100000 : 27
unordered_map 100000:100000 : 25
map 100000:100 : 12
unordered_map 100000:100 : 8
map 10000:10 : 0
unordered_map 10000:10 : 1
map 1000:5 : 0
unordered_map 1000:5 : 0

*/

int main() {
	size_t tests[] = {
		1000000, 100000,
		100000, 100000,
		100000, 100,
		10000, 10,
		1000, 5};
	clock_t c1, c2;

	for( int t=0; t<sizeof(tests)/sizeof(tests[0]); t+=2 ) {
		map<int, int> m;
		unordered_map<int, int> um;

		srand(SRAND);
		c1 = clock();
		for(int i=0; i<tests[t]; i++) {
			int rnd = rand()%tests[t+1];
			m.insert( make_pair( rnd, 1) );
			m[ rnd ];
			m.find(-1);
		}
		c2 = clock();
		cout << "map " << tests[t] << ":" << tests[t+1] << " : " << c2-c1 << endl;

		srand(SRAND);
		c1 = clock();
		for(int i=0; i<tests[t]; i++) {
			int rnd = rand()%tests[t+1];
			um.insert( make_pair( rnd, 1) );
			um[ rnd ];
			m.find(-1);
		}
		c2 = clock();
		cout << "unordered_map " << tests[t] << ":" << tests[t+1] << " : " << c2-c1 << endl;
	}
	return 0;
}
